package com.hm.hsw3;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class Demo {
    public static void main(String[] args) throws Exception {
        //简单方便书写,但是因为只能单继承,不利于功能扩展
        MyThread mt = new MyThread();
        mt.start();
        //书写比之1略显复杂,但是因为是实现了接口,所以功能扩展比较方便
        Thread rt = new Thread(new MyRunnable());
        rt.start();
        //书写比之12较为复杂,但是可以带回返回值
        Callable<String> callable = () -> "我是一个忧伤的子线程";
        FutureTask<String> ft = new FutureTask<>(callable);
        Thread cft = new Thread(ft);
        cft.start();
        String s = ft.get();
        System.out.println(s);
    }
}
